﻿@inject IOptionsSnapshot<SiteOptions> SiteOptions
@inject ILinkService Service
@inject IDistributedCacheHelper CacheHelper

@{
    const string cacheKeyForLinks = "_LinkPartial";

    async Task<List<LinkBrief>?> GetDataFromDb()
    {
        return await Service.GetListAsync();
    }

    var datas = await CacheHelper.GetOrCreateAsync(cacheKeyForLinks,
        async e => await GetDataFromDb());
}

<div class="links whitebg box ">
    <div class="news-title">
        <h2>友情链接</h2>
    </div>
    <ul>
        @if (datas is {Count:>0})
        {
            @foreach (var link in datas)
            {
                <li>
                    <a href="@link.Url" title="@link.Description" target="_blank">@link.Name</a>
                </li>
            }
        }
    </ul>
</div>